package vashion.azeroth.api.controller.tran;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import vashion.azeroth.api.controller.base.BaseController;
import vashion.azeroth.core.personal.tran.pojo.PersonalDisburse;
import vashion.azeroth.core.personal.tran.pojo.PersonalSnapshot;
import vashion.azeroth.core.personal.tran.pojo.PersonalSnapshotExt;
import vashion.azeroth.core.result.ApiResult;
import vashion.azeroth.core.service.tran.PersonalDisburseService;
import vashion.azeroth.core.service.tran.PersonalSnapshotService;

@Controller
@RequestMapping("/tran/")
public class ReturnGoodsController extends BaseController {

	@Autowired
	private PersonalDisburseService<PersonalDisburse> disburseService;
	@Autowired
	private PersonalSnapshotService snapshotService;
	
	/**
	 * 查询退货订单
	 * @param memberId
	 * @return
	 */
	@RequestMapping("queryReturnGoodsOrder")
	@ResponseBody
	public ApiResult<List<PersonalSnapshotExt>> queryReturnGoodsOrder(Long memberId) {
		
		PersonalSnapshot snapshot = new PersonalSnapshot();
		snapshot.setMemberId(memberId);
		
		return snapshotService.queryReturnGoodsOrder(snapshot);
	}
	
	/**
	 * 查询商品可退货信息
	 * @param disburseNo
	 * @param skuId
	 * @return
	 */
	@RequestMapping("queryReturnGoodInfo")
	@ResponseBody
	public ApiResult<PersonalSnapshot> queryReturnGoodInfo(String disburseNo, Long skuId) {
		
		PersonalSnapshot snapshot = new PersonalSnapshot();
		snapshot.setDisburseNo(disburseNo);
		snapshot.setSkuId(skuId);
		
		return snapshotService.queryReturnGoodInfo(snapshot);
	}
	
	/**
	 * 提交退货申请接口
	 * @param memberId
	 * @param snapshot
	 * @return 提交结果
	 */
	@RequestMapping("submitReturnGoodsApply")
	@ResponseBody
	public ApiResult<String> submitReturnGoodsApply(Integer memberId, PersonalSnapshot snapshot) {
		
		return disburseService.submitReturnGoodsApply(snapshot);
	}
	
	/**
	 * 撤销退货申请接口
	 * @param memberId
	 * @param snapshot
	 * @return 撤销结果
	 */
	@RequestMapping("cancelReturnGoodsApply")
	@ResponseBody
	public ApiResult<String> cancelReturnGoodsApply(Integer memberId, PersonalSnapshot snapshot) {
		
		return disburseService.cancelReturnGoodsApply(snapshot);
	}
	
	@RequestMapping("submitLogisticsInfo")
	@ResponseBody
	public ApiResult<String> submitLogisticsInfo(String returnGoodsNo, String logisticsCompany, String logisticsNo) {
		
		return disburseService.submitLogisticsInfo(returnGoodsNo, logisticsCompany, logisticsNo);
	}
	
}
